<!--
 * @Author       : wfl
 * @LastEditors: ww
 * @description  :
 * @updateInfo   :
 * @Date         : 2023-05-08 17:54:20
 * @LastEditTime: 2023-06-30 16:22:05
-->
<script lang="ts" setup name="BaseModalCopy">
import { useLinear } from '@main/views/approve-workflow/useLinear'

const props = defineProps({
  data: {
    type: Object,
    default: () => { }
  },
  modelValue: {
    type: Boolean,
    default: false
  },
  type: {
    type: String,
    default: 'group' // group form
  }
})

const emits = defineEmits(['update:modelValue'])
const isShow = computed(() => props.modelValue)
// const activeGroup = ref('')

const handleClose = () => {
  emits('update:modelValue', false)
}

// const handConfirm = async () => {

// }

const { getLinearGradient } = useLinear()
</script>

<template>
  <el-dialog
    v-model="isShow"
    class="iflow_base-copy-modal"
    draggable
    title="复制已有模板"
    width="630"
    align-center
    @close="handleClose"
  >
    <template v-for="item in data" :key="item.id">
      <template v-if="item.forms?.length">
        <p>{{ item.name }}</p>
        <div class="form-info">
          <el-card v-for="form in item.forms" :key="form.id">
            <div class="icon-name">
              <div class="form-icon" :style="{ backgroundImage: getLinearGradient(form?.iconBackground) }">
                <i :class="`ikflow ${form.icon}`"></i>
              </div>
              <div class="form-name">
                {{ form.name }}
              </div>
            </div>
          </el-card>
        </div>
      </template>
    </template>
  </el-dialog>
</template>

<style lang="scss">
.iflow_base-copy-modal {
  .form-info {
    display: flex;
    flex-wrap: wrap;

    .el-card {
      width: 180px;
      margin-bottom: 8px;
      cursor: pointer;

      &:hover {
        border-color: var(--el-color-primary);
      }

      &:not(:last-child) {
        margin-right: 8px;
      }

      .el-card__body {
        padding: 12px;

        .icon-name {
          display: flex;
          align-items: center;
        }
      }
    }
  }

  .form-name {
    display: inline-block;
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    word-break: keep-all;
  }

  p {
    margin-bottom: 18px;

    &:not(:first-child) {
      margin-top: 18px;
    }
  }

}
</style>
